package com.zqxq.lottery.service.analysis.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.zqxq.common.constant.Result;
import com.zqxq.common.enums.CodeEnum;
import com.zqxq.common.utils.StrUtils;
import com.zqxq.lottery.entity.po.analysis.AnalysisForecastPO;
import com.zqxq.lottery.mapper.analysis.AnalysisForecastMapper;
import com.zqxq.lottery.service.analysis.IAnalysisForecastService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Slf4j
public class AnalysisForecastServiceImpl extends ServiceImpl<AnalysisForecastMapper, AnalysisForecastPO> implements IAnalysisForecastService {
    @Override
    public Map<String, Object> getOfficialVote(String code) {
        Map<String,Object> map = null;
        if (StrUtils.isEmpty(code)) {
            return map;
        }
        Wrapper<AnalysisForecastPO> wrapper = new EntityWrapper<>();
        wrapper.eq("code",code);
        AnalysisForecastPO analysisForecastPO = this.selectOne(wrapper);
        if (analysisForecastPO != null){
            if (StrUtils.isNotEmpty(analysisForecastPO.getSpf_vote())){
                map = (Map) JSONObject.parse(analysisForecastPO.getSpf_vote());
            }
        }
        return map;
    }
}
